include url in json output
authorJoey Hess <joeyh@joeyh.name>
Tue, 9 May 2023 20:59:44 +0000 (16:59 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 9 May 2023 20:59:44 +0000 (16:59 -0400)
The input field is consistently the url of the feed, which makes sense
as that is the user input, but to differentiate multiple urls downloaded
from a feed when using --json-progress -J, need the url that is being
downloaded too.

Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
Command/ImportFeed.hs

index 2901e7628f4a67a618806a99fa9db7c1c8a87f6d..79c3db2943cb13866575a671972fe18ac1d85661 100644 (file)
@@ -459,14 +459,18 @@ runDownload todownload url extension cache cv getter = do
                        )
 
 startUrlDownload :: TMVar Bool -> ToDownload -> URLString -> CommandPerform -> CommandStart
-startUrlDownload cv todownload url a = starting "addurl"
-       (ActionItemOther (Just (UnquotedString url)))
-       (SeekInput [feedurl todownload])
-       (a `onException` recordfailure)
+startUrlDownload cv todownload url a = do
+       starting "addurl"
+               (ActionItemOther (Just (UnquotedString url)))
+               (SeekInput [feedurl todownload])
+               (go `onException` recordfailure)
   where
        recordfailure = do
                void $ feedProblem url "download failed"
                liftIO $ atomically $ tryPutTMVar cv False
+       go = do
+               maybeAddJSONField "url" url
+               a
 
 defaultTemplate :: String
 defaultTemplate = "${feedtitle}/${itemtitle}${extension}"